var express = require('express');
const {handleRequest,handleRequestBuyRoom} = require("../service/orders/ordersQuery");
const {orderQueryAllError,orderInsertError} = require('../common/resultcode')
// const order = require("../moudles/accessdb/dao/orderQuery");
var router = express.Router();

/* GET home page. */
router.get('/', async function (req,
                                res,
                                next) {
    console.log('order')
    const {page,limit}=req.query;
    handleRequest(parseInt(page),parseInt(limit))
        .then((resp) => {
            res.send(resp)
        }).catch((e) => {
        res.send(orderQueryAllError)
    })
});
/**
 * 种类id查询 房间
  */
router.post('/', async function (req,
                                                         res,
                                                         next) {
    console.log('buy')
    await handleRequestBuyRoom(req.body)
        .then((resp) => {
            //插入成功了
            res.send(resp)
        }).catch((e) => {
        res.send(orderInsertError)
    })
});
// router.post('/buyroom', async function (req,
//                                                       res,
//                                                       next) {
//     console.log('房间')
//     handleRequestByQueryRoom(req.body)
//         .then((resp) => {
//             res.send(resp)
//         }).catch((e) => {
//         res.send(roomQueryAllError)
//     })
// });
module.exports = router;